package com.stupro.cjlu.controller;


import com.stupro.cjlu.bo.LoginStatusBO;
import com.stupro.cjlu.common.vo.ResultVO;
import com.stupro.cjlu.common.vo.TeacherCourseItemVO;
import com.stupro.cjlu.common.vo.TeacherInsertVO;
import com.stupro.cjlu.dao.StudentCourseDAO;
import com.stupro.cjlu.entity.Course;
import com.stupro.cjlu.entity.Students;
import com.stupro.cjlu.entity.Teacher;
import com.stupro.cjlu.service.CourseService;
import com.stupro.cjlu.service.RoomService;
import com.stupro.cjlu.service.StudentsService;
import com.stupro.cjlu.service.TeacherService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Collection;
import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Administrator
 * @since 2021-05-10
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController extends BaseController {

    @Autowired
    private TeacherService teacherService;

    @Autowired
    private StudentsService studentsService;

    @Autowired
    private CourseService courseService;

    @Autowired
    private RoomService roomService;

    @ApiOperation("获取该教师全部课程,没有分页")
    @GetMapping("/getMyCourse")
    public ResultVO getMyCourse(int teaID){
        return teacherService.getCourseById(teaID);
    }

    @ApiOperation("获取全部教室")
    @GetMapping("/getRoom")
    public ResultVO getRoom(){
        return roomService.getRoom();
    }

    @ApiOperation("获取学生成绩")
    @GetMapping("/getStudentGrade")
    public ResultVO getStudentGrade(int page,String courseName,String stuName,HttpSession session){
        LoginStatusBO teacher = (LoginStatusBO) session.getAttribute("user_status");
        int teacherID = teacher.getUserId();
        return studentsService.getCourse(page,stuName,null,courseName,teacherID);
    }

    @ApiOperation("添加课程")
    @PostMapping("/addCourse")
    public ResultVO addCourse(@RequestBody Course course){
        return courseService.addCourse(course);
    }

    @ApiOperation("删除课程")
    @GetMapping("/delCourse")
    public ResultVO delCourse(int teacherId,int courseId){
        return null;
    }

    @ApiOperation("检查密码,无用接口")
    @GetMapping("/checkPwd")
    public ResultVO checkPwd(int teacherId,String pwd){
        return teacherService.checkPwd(teacherId,pwd);
    }

    @ApiOperation("修改密码")
    @PostMapping("/changePwd")
    public ResultVO changePwd(@RequestBody TeacherInsertVO teacher, HttpSession session){
        return teacherService.changePwd(teacher);
    }
    @ApiOperation("修改学生成绩")
    @GetMapping("/changeGrade")
    public ResultVO changeGrade(int scID,int grade){
        return teacherService.changeGrade(scID,grade);
    }
}
